package com.detooa.detooa.config;

import java.io.IOException;
import java.util.Properties;

import com.detooa.detooa.utils.PropertiesUtils;

import lombok.extern.log4j.Log4j2;

/**
 * OA系统配置类
 */
@Log4j2
public class OaConfig {
    public final static String BASE_URL;// = "http://10.11.1.28:8089";
    public final static String APPID;// = "fzybi2";
    public final static int EXPIRE_TIME;// token过期时间
    public final static String CODE;// 默认消息来源

    static {
        Properties properties = new Properties();
        try {
            properties = PropertiesUtils.readProperties("oa.properties");
        } catch (IOException e) {
            log.error("DataEase初始化失败...");
            e.printStackTrace();
        }
        BASE_URL = properties.getProperty("oa.base_url");// (String) properties.getOrDefault("oa.base_url");
        APPID = properties.getProperty("oa.appid");// (String) properties.getOrDefault("oa.appid");
        EXPIRE_TIME = Integer.valueOf(properties.getProperty("oa.expire_time"));// Integer.valueOf((String) properties.getOrDefault("oa.expire_time",
                                                                                // "1800"));
        CODE = properties.getProperty("oa.code");// (String) properties.getOrDefault("oa.code", "1152");

        if (null == BASE_URL || null == APPID || 0 == EXPIRE_TIME || null == CODE) {
            log.error("OaConfig初始化失败...");
        } else {
            log.info("OaConfig初始化成功...");
        }
    }
}
